#!/usr/bin/python
import xmlrpclib
import clientFuncs
import time
import enronMain

rpcObj  = xmlrpclib.ServerProxy('http://172.18.56.106:8000')
cFuncs  = None

taskKey = rpcObj.nextTask()
print 'Processing Task: ' + taskKey
while taskKey != 'NONE': 
    if taskKey != None:
        cFuncs = clientFuncs.clientFuncs(rpcObj, taskKey)
        cFuncs.start()
    else:
        print 'Error: taskKey=',
        print taskKey

    ''' Dispatch Task Here'''
    enronMain.handleWebRequest(taskKey)
    print 'Processing Task: ' + taskKey
    cFuncs.stop()
    cFuncs.join()
    rpcObj.updateStatus('SUCCESS', taskKey)
    taskKey = rpcObj.nextTask()
